import Main from '@/components/main'
import parentView from '@/components/parent-view'
import Vue from 'vue'
/**
 * iview-admin中meta除了原生参数外可配置的参数:
 * meta: {
 *  title: { String|Number|Function }
 *         显示在侧边栏、面包屑和标签栏的文字
 *         使用'{{ 多语言字段 }}'形式结合多语言使用，例子看多语言的路由配置;
 *         可以传入一个回调函数，参数是当前路由对象，例子看动态路由和带参路由
 *  hideInBread: (false) 设为true后此级路由将不会出现在面包屑中，示例看QQ群路由配置
 *  hideInMenu: (false) 设为true后在左侧菜单不会显示该页面选项
 *  notCache: (false) 设为true后页面在切换标签后不会缓存，如果需要缓存，无需设置这个字段，而且需要设置页面组件name属性和路由配置的name一致
 *  access: (null) 可访问该页面的权限数组，当前路由设置的权限会影响子路由
 *  icon: (-) 该页面在左侧菜单、面包屑和标签导航处显示的图标，如果是自定义图标，需要在图标名称前加下划线'_'
 *  beforeCloseName: (-) 设置该字段，则在关闭当前tab页时会去'@/router/before-close.js'里寻找该字段名对应的方法，作为关闭前的钩子函数
 * }
 */
let routes0=[
  {
    path: '/login',
    name: 'login',
    meta: {
      title: 'Login - 登录',
      hideInMenu: true
    },
    component: () => import('@/view/login/login.vue')
  },
  {
    path: '/401',
    name: 'error_401',
    meta: {
      hideInMenu: true
    },
    component: () => import('@/view/error-page/401.vue')
  },
  {
    path: '/500',
    name: 'error_500',
    meta: {
      // hideInMenu: true
    },
    component: () => import('@/view/error-page/500.vue')
  },
  {
    path: '*',
    name: 'error_404',
    meta: {
      hideInMenu: true
    },
    component: () => import('@/view/error-page/404.vue')
  }
]
let routes1=[
  {
    path: '/login',
    name: 'login',
    meta: {
      title: 'Login - 登录',
      hideInMenu: true
    },
    component: () => import('@/view/login/login.vue')
  },
  {
    path: '/',
    name: 'home',
    meta: {
      hideInBread: true,
      title: '电厂级首页',
      hideInMenu: isShow('/')
    },
    component: Main,
    children: [
      {
        path: '/',
        name: 'home',
        meta: {
          icon: 'md-home',
          title: '电厂级首页'
        },
        component: () => import('@/view/single-page/home')
      }
    ]
  },
  {
    path: '/home2',
    name: '机组级首页',
    meta: {
      hideInBread: true,
      hideInMenu: true
    },
    component: Main,
    children: [
      {
        path: '/home2',
        name: '机组级首页',
        meta: {
          icon: 'md-home',
          title: '机组级首页',
          hideInMenu: isShow('/home2')
        },
        component: () => import('@/view/single-page/home/home2')
      }
    ]
  },
  {
    path: '/message',
    name: 'message',
    component: Main,
    meta: {
      hideInBread: true,
      hideInMenu: true
    },
    children: [
      {
        path: 'message_page',
        name: 'message_page',
        meta: {
          icon: 'md-notifications',
          title: '消息中心',
          hideInMenu: isShow('/message')
        },
        component: () => import('@/view/single-page/message/index.vue')
      }
    ]
  },
  {
    path: '/state',
    name: '状态管理',
    meta: {
      icon: 'md-analytics',
      title: '状态管理',
      hideInMenu: isShow2(['stateMonitor','alarmRecord','onlineTrend','offlineTrend'])
    },
    component: Main,
    children: [
      {
        path: 'stateMonitor',
        name: '状态监测',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '状态监测',
          hideInMenu: isShow('stateMonitor')
        },
        component: () => import('@/view/state/stateMonitor.vue')
      },
      {
        path: 'alarmRecord',
        name: '状态监测',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '报警记录',
          hideInMenu:true
        },
        component: parentView,
        children:[
          {
            path: 'alarmRecord',
            name: '状态监测',
            meta: {
              icon: 'md-arrow-dropright-circle',
              title: '报警记录'
            },
            component:parentView,
            children:[
              {
                path: 'alarmRecord',
                name: '报警记录',
                meta: {
                  icon: 'md-arrow-dropright-circle',
                  title: '报警记录'
                },
                component: () => import('@/view/state/alarmRecord/alarmRecord.vue'),
              }
            ]
          }
        ]
      },
      {
        path: 'onlineTrend',
        name: '在线趋势分析',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '在线趋势分析',
          hideInMenu: isShow('onlineTrend')
        },
        component: () => import('@/view/state/onlineTrend.vue')
      },
      {
        path: 'offlineTrend',
        name: '离线趋势分析',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '离线趋势分析',
          hideInMenu: isShow('offlineTrend')
        },
        component: () => import('@/view/state/offlineTrend.vue')
      },
      {
        path: 'tab',
        name: '离线趋势分析',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '离线趋势分析',
          hideInMenu:true
        },
        component: parentView,
        children:[
          {
            path: 'tab2',
            name: '离线趋势分析',
            meta: {
              icon: 'md-arrow-dropright-circle',
              title: '离线趋势分析',
              hideInMenu: false
            },
            component: () => import('@/view/state/tab/tab2.vue')
          },
          {
            path: 'tab3',
            name: '离线趋势分析',
            meta: {
              icon: 'md-arrow-dropright-circle',
              title: '离线趋势分析',
              hideInMenu: false
            },
            component: () => import('@/view/state/tab/tab3.vue')
          },
          {
            path: 'tab4',
            name: '离线趋势分析',
            meta: {
              icon: 'md-arrow-dropright-circle',
              title: '离线趋势分析',
              hideInMenu: false
            },
            component: () => import('@/view/state/tab/tab4.vue')
          },
          {
            path: 'tab5',
            name: '离线趋势分析',
            meta: {
              icon: 'md-arrow-dropright-circle',
              title: '离线趋势分析',
              hideInMenu: false
            },
            component: () => import('@/view/state/tab/tab5.vue')
          }
        ]
      },
    ]
  },
  {
    path: '/runManage',
    name: '运行管理',
    meta: {
      icon: 'md-desktop',
      title: '运行管理',
      hideInMenu: isShow2(['nowState','stateWait','stateRecord'])
    },
    component: Main,
    children: [
      {
        path: 'nowState',
        name: '机组当前状态',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '机组当前状态',
          hideInMenu: isShow('nowState')
        },
        component: () => import('@/view/runManage/nowState.vue')
      },
      {
        path: 'stateWait',
        name: '机组状态待办',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '机组状态待办',
          hideInMenu: isShow('stateWait')
        },
        component: () => import('@/view/runManage/stateWait.vue')
      },
      {
        path: 'stateRecord',
        name: '机组状态记录',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '机组状态记录',
          hideInMenu: isShow('stateRecord')
        },
        component: () => import('@/view/runManage/stateRecord.vue')
      }
    ]
  },
  {
    path: '/problem',
    name: '问题管理',
    meta: {
      icon: 'ios-bug',
      title: '问题管理',
      hideInMenu: isShow2(['eventRecord','tefectTracking'])
    },
    component: Main,
    children: [
      {
        path: 'eventRecord',
        name: '事件记录',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '事件记录',
          hideInMenu: isShow('eventRecord')
        },
        component: () => import('@/view/problem/eventRecord.vue')
      },
      {
        path: 'tefectTracking',
        name: '问题跟踪',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '问题跟踪',
          hideInMenu: isShow('tefectTracking')
        },
        component: () => import('@/view/problem/tefectTracking.vue')
      }
    ]
  },
  {
    path: '/test',
    name: '试验管理',
    meta: {
      icon: 'md-flask',
      title: '试验管理',
      hideInMenu: isShow2(['testPlan','testCheck','testRecord'])
    },
    component: Main,
    children: [
      {
        path: 'testPlan',
        name: '试验计划',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '试验计划',
          hideInMenu: isShow('testPlan')
        },
        component: () => import('@/view/test/testPlan.vue')
      },
      {
        path: 'testCheck',
        name: '启动前检查记录',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '启动前检查记录',
          hideInMenu: isShow('testCheck')
        },
        component: parentView,
        children:[
          {
            path: 'testCheck',
            name: 'UD45',
            meta: {
              icon: 'md-arrow-dropright-circle',
              title: 'UD45'
            },
            component: () => import('@/view/test/testCheck.vue')
          },
          {
            path: 'testCheck2',
            name: 'MTU',
            meta: {
              icon: 'md-arrow-dropright-circle',
              title: 'MTU'
            },
            component: () => import('@/view/test/testCheck2.vue')
          },
        ]
      },
      {
        path: 'testRecord',
        name: '试验记录',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '试验记录',
          hideInMenu: isShow('testRecord')
        },
        component: parentView,
        children:[
          {
            path: 'testRecord',
            name: '月度试验(MTU)',
            meta: {
              icon: 'md-arrow-dropright-circle',
              title: '月度试验(MTU)'
            },
            component: () => import('@/view/test/testRecord.vue')
          },
          {
            path: 'testRecord2',
            name: '月度试验(UD45)',
            meta: {
              icon: 'md-arrow-dropright-circle',
              title: '月度试验(UD45)'
            },
            component: () => import('@/view/test/testRecord2.vue')
          },
          {
            path: 'testRecord3',
            name: '再鉴定(LHS热备用)',
            meta: {
              icon: 'md-arrow-dropright-circle',
              title: '再鉴定(LHS热备用)'
            },
            component: () => import('@/view/test/testRecord3.vue')
          },
          {
            path: 'testRecord4',
            name: '再鉴定(LHS运行)',
            meta: {
              icon: 'md-arrow-dropright-circle',
              title: '再鉴定(LHS运行)'
            },
            component: () => import('@/view/test/testRecord4.vue')
          },
          {
            path: 'testRecord5',
            name: '再鉴定(MTU)',
            meta: {
              icon: 'md-arrow-dropright-circle',
              title: '再鉴定(MTU)'
            },
            component: () => import('@/view/test/testRecord5.vue')
          },
          {
            path: 'testRecord6',
            name: '再鉴定(UD45)',
            meta: {
              icon: 'md-arrow-dropright-circle',
              title: '再鉴定(UD45)'
            },
            component: () => import('@/view/test/testRecord6.vue')
          }
        ]
      },
    ]
  },
  {
    path: '/repair',
    name: '维修管理',
    meta: {
      icon: 'md-build',
      title: '维修管理',
      hideInMenu: isShow2(['repairPlan','repairRecord'])
    },
    component: Main,
    children: [
      {
        path: 'repairPlan',
        name: '维修计划',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '维修计划',
          hideInMenu: isShow('repairPlan')
        },
        component: () => import('@/view/repair/repairPlan.vue')
      },
      {
        path: 'repairRecord',
        name: '维修记录',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '维修记录',
          hideInMenu: isShow('repairRecord')
        },
        component: () => import('@/view/repair/repairRecord.vue')
      }
    ]
  },
  {
    path: '/base',
    name: '基础数据',
    meta: {
      icon: 'md-globe',
      title: '基础数据',
      hideInMenu: isShow2(['unitFile','deviceClass','fileManage'])
    },
    component: Main,
    children: [
      {
        path: 'unitFile',
        name: '机组档案',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '机组档案',
          hideInMenu: isShow('unitFile')
        },
        component: () => import('@/view/base/unitFile.vue')
      },
      {
        path: 'unitFileDetail',
        name: '机组档案详情',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '机组档案详情',
          hideInMenu: true
        },
        component: () => import('@/view/base/unitFileDetail.vue')
      },
      {
        path: 'deviceClass',
        name: '设备分类',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '设备分类',
          hideInMenu: isShow('deviceClass')
        },
        component: () => import('@/view/base/deviceClass.vue')
      },
      {
        path: 'fileManage',
        name: '文件管理',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '文件管理',
          hideInMenu: isShow('fileManage')
        },
        component: () => import('@/view/base/fileManage.vue')
      }
    ]
  },
  {
    path: '/search',
    name: '搜索结果',
    meta: {
      hideInMenu: true
    },
    component: Main,
    children: [
      {
        path: 'searchResult',
        name: '搜索结果',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '搜索结果',
          hideInMenu: isShow('/search')
        },
        component: () => import('@/view/search/searchResult.vue')
      }
    ]
  },
  {
    path: '/feed',
    name: '经验反馈',
    meta: {
      hideInBread: true,
      hideInMenu: isShow('/feedback')
    },
    component: Main,
    children: [
      {
        path: '/feedback',
        name: '经验反馈',
        meta: {
          icon: 'md-list-box',
          title: '经验反馈',
          hideInMenu: isShow('/feedback')
        },
        component: () => import('@/view/feedback/feedback.vue')
      }
    ]
  },
  {
    path: '/member',
    name: '个人中心',
    meta: {
      icon: 'md-person',
      title: '个人中心',
      hideInMenu: isShow2(['workWait'])
    },
    component: Main,
    children: [
      {
        path: 'workWait',
        name: '工作待办',
        meta: {
          icon: 'md-person',
          title: '工作待办',
          hideInMenu: isShow('workWait')
        },
        component: () => import('@/view/member/workWait.vue')
      }
      // {
      //   path: 'workReport',
      //   name: '工作周报',
      //   meta: {
      //     icon: 'md-arrow-dropright-circle',
      //     title: '工作周报'
      //   },
      //   component: () => import('@/view/member/workReport.vue')
      // }
    ]
  },
  {
    path: '/system',
    name: '系统管理',
    meta: {
      icon: 'md-settings',
      title: '系统管理',
      hideInMenu: isShow2(['role','user','middleware','data','dict'])
    },
    component: Main,
    children: [
      {
        path: 'role',
        name: '角色管理',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '角色管理',
          hideInMenu: isShow('role')
        },
        component: () => import('@/view/system/role.vue')
      },
      {
        path: 'user',
        name: '用户管理',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '用户管理',
          hideInMenu: isShow('user')
        },
        component: () => import('@/view/system/user.vue')
      },
      {
        path: 'middleware',
        name: '中间件管理',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '中间件管理',
          hideInMenu: isShow('middleware')
        },
        component: () => import('@/view/system/middleware.vue')
      },
      {
        path: 'data',
        name: '指标数据维护',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '指标数据维护',
          hideInMenu: isShow('data')
        },
        component: () => import('@/view/system/data.vue')
      },
      {
        path: 'dict',
        name: '字典表管理',
        meta: {
          icon: 'md-arrow-dropright-circle',
          title: '字典表管理',
          hideInMenu: isShow('dict')
        },
        component: () => import('@/view/system/dict.vue')
      }
    ]
  },
  {
    path: '/401',
    name: 'error_401',
    meta: {
      hideInMenu: true
    },
    component: () => import('@/view/error-page/401.vue')
  },
  {
    path: '/500',
    name: 'error_500',
    meta: {
      // hideInMenu: true
    },
    component: () => import('@/view/error-page/500.vue')
  },
  {
    path: '*',
    name: 'error_404',
    meta: {
      hideInMenu: true
    },
    component: () => import('@/view/error-page/404.vue')
  }
]
function isShow(path){
  if(localStorage.getItem('qxmenu')){
    let qxmenu=JSON.parse(localStorage.getItem('qxmenu'))
    if(qxmenu.indexOf(path)!=-1){
      return true
    }else{
      return false
    }
  }else{
    return false
  }

}
function isShow2(path){
  if(localStorage.getItem('qxmenu')){
  let qxmenu=JSON.parse(localStorage.getItem('qxmenu'))
  let patharry=path
  return patharry.every(val => qxmenu.includes(val));
  }else{
    return false
  }
}
var routes=[];
if(localStorage.getItem('qxmenu')){
  routes=routes1;
}else{
  routes=routes0
}
export default routes
